home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / EXCEPT.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  184 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1993, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.8  $
  6. //
  7. // ObjectWindows exception class & function definitions
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_EXCEPT_H)
  10. #define OWL_EXCEPT_H
  11.  
  12. #if !defined(OWL_DEFS_H)
  13. # include <owl/defs.h>
  14. #endif
  15. #if !defined(SERVICES_EXCEPT_H)
  16. # include <services/except.h>
  17. #endif
  18. #if !defined(WINSYS_EXBASE_H)
  19. # include <winsys/exbase.h>
  20. #endif
  21. #include <owl/except.rh>
  22.  
  23. #if defined(BI_NAMESPACE)
  24. namespace OWL {
  25. #endif
  26.  
  27. // Generic definitions/compiler options (eg. alignment) preceeding the
  28. // definition of classes
  29. #include <services/preclass.h>
  30.  
  31. class _OWLCLASS TModule;
  32. extern TModule* Module;  // Global Module ptr in each DLL/EXE
  33.  
  34. //
  35. // Global function to handle exceptions in OWL as a last resort
  36. //
  37. int _OWLFUNC HandleGlobalException(xmsg& x, char* caption, char* canResume=0);
  38.  
  39. //
  40. // class TXOwl
  41. // ~~~~~ ~~~~~
  42. // TXOwl is root class of the ObjectWindows exception hierarchy.
  43. //
  44. class _OWLCLASS_RTL TXOwl : public TXBase {
  45.   public:
  46.     TXOwl(const string& msg, uint resId = 0);
  47.     TXOwl(uint resId, TModule* module = ::Module);
  48.    ~TXOwl();
  49.  
  50.     // Override TXBase's virtuals
  51.     //
  52. #if defined(BI_NO_COVAR_RET)
  53.     TXBase* Clone();
  54. #else
  55.     TXOwl* Clone();
  56. #endif
  57.     void Throw();
  58.  
  59.     // Per-exception class unhandled-handler, will default to the per-module
  60.     // unhandled-handler
  61.     //
  62.     virtual int Unhandled(TModule* appModule, uint promptResId);
  63.  
  64.     uint GetErrorCode() const;
  65.  
  66.     static string ResourceIdToString(bool* found, uint resId,
  67.                                      TModule* module = ::Module);
  68.     static string MakeMessage(uint resId, const char far* infoStr, TModule* module = ::Module);
  69.     static string MakeMessage(uint resId, uint infoNum, TModule* module = ::Module);
  70.  
  71.     static void Raise(const string& msg, uint resId = 0);
  72.     static void Raise(uint resId, TModule* module = ::Module);
  73.  
  74.   public:
  75.     uint ResId;
  76. };
  77.  
  78. //
  79. // class TXOutOfMemory
  80. // ~~~~~ ~~~~~~~~~~~~~
  81. class _OWLCLASS_RTL TXOutOfMemory : public TXOwl {
  82.   public:
  83.     TXOutOfMemory();
  84.  
  85. #if defined(BI_NO_COVAR_RET)
  86.     TXBase* Clone();
  87. #else
  88.     TXOutOfMemory* Clone();
  89. #endif
  90.     void   Throw();
  91.  
  92.     static void Raise();
  93. };
  94.  
  95.  
  96. // Generic definitions/compiler options (eg. alignment) following the
  97. // definition of classes
  98. #include <services/posclass.h>
  99.  
  100. #if defined(BI_NAMESPACE)
  101. } //namespace OWL
  102. #endif
  103.  
  104. #if defined(OWL1_COMPAT)
  105.  
  106. #if defined(BI_NAMESPACE)
  107. namespace OWL {
  108. #endif
  109.  
  110. //----------------------------------------------------------------------------
  111. // Owl 1.0 compatibility exception classes
  112. //
  113.  
  114. //
  115. // class TXCompatibility
  116. // ~~~~~ ~~~~~~~~~~~~~~~
  117. class _OWLCLASS_RTL TXCompatibility : public TXOwl {
  118.   public:
  119.     TXCompatibility(int statusCode);
  120.     TXCompatibility(const TXCompatibility& src);
  121.  
  122. #if defined(BI_NO_COVAR_RET)
  123.     TXBase* Clone();
  124. #else
  125.     TXCompatibility* Clone();
  126. #endif
  127.     void             Throw();
  128.     int              Unhandled(TModule* app, uint promptResId);
  129.  
  130.     static string MapStatusCodeToString(int statusCode);
  131.  
  132.     // Member containing an OWL-1 compatible status code representing
  133.     // an error condition.
  134.     //
  135.     int Status;
  136. };
  137.  
  138. //
  139. // class TStatus
  140. // ~~~~~ ~~~~~~~
  141. class _OWLCLASS TStatus {
  142.   public:
  143.     TStatus();
  144.     TStatus& operator =(int statusCode);
  145.     operator int() const;
  146.  
  147.   private:
  148.     void Set(int statusCode);
  149.     int  StatusCode;
  150. };
  151.  
  152. #if defined(BI_NAMESPACE)
  153. } // namespace OWL
  154. #endif
  155.  
  156. //----------------------------------------------------------------------------
  157. // Inline implementations
  158. //
  159.  
  160. //
  161. inline TStatus::TStatus() {
  162.   StatusCode = 0;
  163. }
  164.  
  165. //
  166. inline TStatus& TStatus::operator =(int statusCode) {
  167.   Set(statusCode);
  168.   return *this;
  169. }
  170.  
  171. //
  172. inline TStatus::operator int() const {
  173.   return StatusCode;
  174. }
  175.  
  176. #endif  // if defined(OWL1_COMPAT)
  177.  
  178. //
  179. inline uint TXOwl::GetErrorCode() const {
  180.   return ResId;
  181. }
  182.  
  183. #endif  // OWL_EXCEPT_H
  184.